package com.oa.service;

import com.oa.bean.Dept;
import com.oa.bean.PageInfo;
import com.oa.dao.DeptDao;

import java.util.List;

public class DeptServiceImpl implements  DeptService {

    //获取Dao的对象
    DeptDao deptDao = new DeptDao();

    @Override
    public boolean insertDept(Dept dept) {
        return deptDao.insertDept(dept);
    }

    @Override
    public boolean deleteDept(int id) {
        return deptDao.deleteDept(id);
    }

    @Override
    public boolean updateDept(Dept dept) {
        return deptDao.updateDept(dept);
    }

    @Override
    public List<Dept> queryDept(PageInfo page, String... limit) {
        return deptDao.queryDept(page,limit);
    }

    @Override
    public Dept queryDeptById(int deptId) {
        return deptDao.queryDeptById(deptId);
    }

    @Override
    public int queryDeptCount(String... limit) {
        return deptDao.queryDeptCount(limit);
    }

    @Override
    public List<Dept> queryDeptByMatchName(PageInfo page, String name) {
        String[]param = {"name like  concat('%'," + '?' + ",'%') ",
                name};
        return queryDept(page,param);
    }

    @Override
    public int queryDeptByMatchNameCount(String name) {
        String[]param = {"name like  concat('%'," + '?' + ",'%') ",
                name};
        return queryDeptCount(param);
    }

    @Override
    public List<Dept> queryDept() {
        return deptDao.queryDept();
    }
}
